package gupao.concurrency.threads;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class ThreadJoinDemo {

    public static void main(String[] args) throws InterruptedException {
        mainThreadJoinT1();
    }

    private static void mainThreadJoinT1() throws InterruptedException {
        log.info("{} thread running..", Thread.currentThread().getName());

        Thread t = new Thread(() -> {
            for (int i = 0; i < 10; i++){
                log.info("{} thread running..", Thread.currentThread().getName());
                Utils.sleepIgnoreExp(1000);
            }
        }, "t1");
        t.start();
        log.info("{} thread call {}'s join", Thread.currentThread().getName(),t.getName());
        t.join();
        log.info("Thread {} continue. {} thread: {}",Thread.currentThread().getName(), t.getName(), t.getState());
        Utils.sleepIgnoreExp(1000);
        log.info("{} thread finished.", Thread.currentThread().getName());
    }

}
